﻿import wx

class GUIFrame(wx.Frame):
    def __init__(self, parent, id, title, stopCsound, procNum):
        wx.Frame.__init__(self, parent, id, title)

        menuBar = wx.MenuBar()
        menu = wx.Menu()
        menu.Append(1, "Close\tCtrl-W", "Close this window")
        self.Bind(wx.EVT_MENU, self.OnTimeToClose, id=1)
        menuBar.Append(menu, "&File")            
        self.SetMenuBar(menuBar)
            
        self.Bind(wx.EVT_CLOSE, self.OnClose)
        self.stopCsound = stopCsound
        self.procNum = procNum
        
    def OnClose(self, event):
        try:
            self.stopCsound(self.procNum)
        except:
            pass
            
    def OnTimeToClose(self, evt):
        self.Close()    